package cf;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class FindFriends {

    public static int[] getResult(int n, int[] height){
        int ans[] = new int[n];
        LinkedList<Integer> stack = new LinkedList<>();
        stack.push(0);
        while (!stack.isEmpty()) {
            int index = stack.peek();
            if (index == n - 1) {
                while (!stack.isEmpty()) {
                    ans[stack.pop()] = 0;
                }
                return ans;
            }
            if (height[index + 1] <= height[index])
                stack.push(index + 1);
            else {
                while (!stack.isEmpty() && height[stack.peek()] < height[index + 1]) {
                    ans[stack.pop()] = index + 1;
                }
                stack.push(index + 1);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[] height  = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] ans = getResult(n,height);
        for (int i = 0; i < n; i++) {
            System.out.print(ans[i] + " ");
        }
    }
}
